// router的入口文件
// 引入路由
const Router=require('koa-router');
const router=new Router();
const list=require('./list');
const home=require('./home');
const login=require('./login');
const category=require('./category');
const goods=require('./goods');
const order=require('./order');
const upload_image=require('./upload_image');
const campus_announcement=require('./campus_announcement');

/*
// 转移到list里面了
router.get('/',async(ctx)=>{
    ctx.body="首页";
})
router.get('/list',async(ctx)=>{
    ctx.body="列表页";
})
*/
// 如果前端还是访问了http://localhost:5050/,
// 后端依然给它重定向到home

// router.use()
router.use('/list',list.routes(),list.allowedMethods())
router.use('/home',home.routes(),home.allowedMethods())
router.use('/login',login.routes(),login.allowedMethods())
router.use('/category',category.routes(),category.allowedMethods())
router.use('/goods',goods.routes(),goods.allowedMethods())
router.use('/order',order.routes(),order.allowedMethods())
router.use('/upload_image',upload_image.routes(),upload_image.allowedMethods())
router.use('/campus_announcement',campus_announcement.routes(),campus_announcement.allowedMethods())

router.redirect('/','/home');

// 导出router给app.js使用
module.exports=router;